﻿using System;
using System.Web.Mvc;

using Fuse8.ContentManagementFramework.Domain.Special;

namespace Fuse8.ContentManagementFramework.Web.MvcPowered
{
    public class CmsViewResult : ViewResult
    {
        public CmsTemplateTypeKind TemplateType { get; set; }

        public bool IsForPreview { get; set; }

        protected override ViewEngineResult FindView(ControllerContext context)
        {
            ViewEngineResult result = null;

            switch (TemplateType)
            {
                case CmsTemplateTypeKind.MvcForm:
                    break;
                case CmsTemplateTypeKind.MvcRazor:
                    result = IsForPreview ?
                        CmsPreviewRazorViewEngine.GetInstance().FindView(context, ViewName, MasterName, true) :
                        CmsRazorViewEngine.GetInstance().FindView(context, ViewName, MasterName, true);
                    break;
            }

            return result;
        }
    }
}
